package com.ygjy.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.common.dao.BaseDAOImpl;
import com.ygjy.dao.SmUserDAO;
import com.ygjy.pojo.SmUser;

@Repository("smUserDAO")
public class SmUserDAOImpl extends BaseDAOImpl<SmUser> implements SmUserDAO {

	/**
	 * 
	 * 
	 * 
	 * @方法说明: 根据用户名和密码查找用户
	 * @param account
	 * @param passowrd
	 * @return
	 * @作者:徐龙
	 * @日期:2012-3-23
	 */
	public SmUser findByUserAccount(String account, String passowrd) {
		SmUser smuser = null;
		String hql = "from SmUser su where su.dr=0 and su.account=:account and su.password=:passowrd";
		String[] param = new String[] { "account", "passowrd" };
		Object[] obj = { account, passowrd };
		List<SmUser> nflist = super.findByNamedParam(hql, param, obj);
		if (nflist.size() > 0) {
			smuser = nflist.get(0);
		}
		return smuser;
	}

	/**
	 * 
	 * 
	 * @方法说明: 查找用户是否存在
	 * @param account
	 * @return
	 * @作者:xul
	 * @日期:2012-8-31
	 */
	public SmUser findAdminUserIsExist(String account) {
		SmUser smuser = null;
		String hql = "from SmUser su where su.dr=0 and su.islocked='N' and su.account=? ";
		Object[] obj = { account };
		List<SmUser> nflist = super.find(hql, obj);
		if (nflist.size() > 0) {
			smuser = nflist.get(0);
		}
		return smuser;
	}
}
